import request from '@/utils/request.js'

// import store from '@/store'
/**
 * @description: 登录
 * @data {*} ruleForm
 * @return {Promise}
 */
export const loginApi = (ruleForm) => {
  return request({
    method: 'post',
    url: '/api/login',
    data: ruleForm
  })
}
// loginApi(this.ruleForm)

/**
 * @description: 注册
 * @data {*} ruleForm
 * @return {Promise}
 */
export const regApi = (ruleForm) => {
  return request({
    method: 'post',
    url: '/api/reg',
    data: ruleForm
  })
}

/**
 * @description: 获取用户信息
 * @data {*}
 * @return {Promise}
 */
export const userInfoApi = () => {
  return request({
    method: 'get',
    url: '/my/userinfo'
    // headers: {
    //   Authorization: store.state.token
    // }
  })
}
/**
 * @description: 获取menu
 * @data {*}
 * @return {Promise}
 */
export const menusApi = () => {
  return request({
    method: 'get',
    url: '/my/menus'
    // headers: {
    //   Authorization: store.state.token
    // }
  })
}

/**
 * @description: 更新用户信息
 * @data {*}
 * @return {Promise}
 */
export const updateUserApi = (data) => {
  return request({
    method: 'PUT',
    url: '/my/userinfo',
    data: data
    // headers: {
    //   Authorization: store.state.token
    // }
  })
}

/**
 * @description: 更新密码
 * @data {*}
 * @return {Promise}
 */
export const updatePwdApi = (data) => {
  return request({
    method: 'PATCH',
    url: '/my/updatepwd',
    data: data
    // headers: {
    //   Authorization: store.state.token
    // }
  })
}

/**
 * @description: 更新图像
 * @data {*}   avatar
 * @return {Promise}
 */
export const updateImgApi = (data) => {
  return request({
    method: 'PATCH',
    url: '/my/update/avatar',
    data: data
    // headers: {
    //   Authorization: store.state.token
    // }
  })
}
